{{#partial title}}注册 - Rust China{{/partial}}
{{#partial page}}
  <div class="container">
    <div class="row">
      <div class="col-md-9">
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title">注册</h3>
          </div>
          <div class="panel-body">
            <form class="form-horizontal" method="post" action="/user/register" id="registerForm">
              <div class="form-group">
                <label for="inputUsername" class="col-sm-2 control-label">用户名</label>
                <div class="col-sm-4">
                  <input type="text" class="form-control" id="inputUsername" name="username" placeholder="用户名">
                </div>
              </div>

              <div class="form-group">
                <label for="inputEmail" class="col-sm-2 control-label">邮箱</label>
                <div class="col-sm-4">
                  <input type="email" class="form-control" id="inputEmail" name="email" placeholder="邮箱">
                </div>
              </div>
              <div class="form-group">
                <label for="inputPassword" class="col-sm-2 control-label">密码</label>
                <div class="col-sm-4">
                  <input type="password" class="form-control" id="inputPassword" name="password" placeholder="密码">
                </div>
              </div>
              <div class="form-group hidden" id="error">
                <div class="col-sm-offset-2 col-sm-4 text-danger"></div>
              </div>
              <div class="form-group">
                <div class="col-sm-offset-2 col-sm-4">
                  <button type="submit" class="btn btn-default">注册</button>
                </div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
{{/partial}}
{{#partial footer_js}}
    <script>
     var is_ajaxing = false;

     $('#registerForm').ajaxForm({
         beforeSend: function() {
             if (is_ajaxing) {
                 return false;
             }
             is_ajaxing = true;
         },
         complete: function() {
             is_ajaxing = false;
         },
         success: function(data) {
             if (data.status != 0) {
                 $('#error div').text(data.message);
                 $('#error').removeClass('hidden').addClass('show');
             } else {
                 location.href = "/user/login";
             }
         }
     });
    </script>
{{/partial}}
{{~> base~}}
